﻿using com.guojin.mj.net.message.login;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ThisMyLM : EventManager
{
    public Text name, clubname, clubid, grade, allnumber, nownumber, introduction,LM_JianJie;
    public InputField Changeinput, clubidInput, AdmainInput;
    public InputField ZhuanID, ZhuanMoney;
    public GameObject chuji, zhongji,HeadImage;//升级俱乐部时展示那个面板
    public Button UpClubOK;
    public Text LmUptext;//升级联盟提示
    public int UpMsg = 1;
    public string HeadString;
    private void Start()
    {
        DownloadHeadTexture(HeadImage.GetComponent<RawImage>(), HeadString);
        if (SaveDate.GetInstance().JoinLm)
        {
            BindingSource[8].SetActive(true);
        }
        else
        {
            BindingSource[8].SetActive(false);
        }
    }
    public override void InformationSetting()
    {
        Open();
    }
    public void SetPage(LMLitem me,int type)
    {
        if (type!=0)
        {
            BindingSource[7].SetActive(false);//管理员隐藏解散联盟按钮
        }
        clubname.text = me.LmName;
        clubid.text = me.LmId.ToString();
        allnumber.text = me.AllPeople.ToString();
        nownumber.text = me.NowPeople.ToString();
        if (me.AllPeople == 2)
        {
            grade.text = "初级";
        }
        else if (me.AllPeople == 4)
        {
            grade.text = "中级";
        }
        else if (me.AllPeople == 6)
        {
            grade.text = "高级";
        }
        else if (me.AllPeople == 8)
        {
            grade.text = "传说级";
        }
        else
        {
            grade.text = "史诗级";
        }
        name.text = me.CreateName;
        introduction.text = me.Content;
        HeadString = me.Address;
    }
    void Chage()
    {
        BindingSource[0].SetActive(true);
        Changeinput.text = "";
    }
    void ChageOk()
    {
        if (Changeinput.text != "")
        {
            LM_JianJie.text = Changeinput.text;
            MessageManager.GetInstance().Send7125(int.Parse(clubid.text), Changeinput.text);
            Changeinput.text = "";
            BindingSource[0].SetActive(false);
        }
        else
        {
            TooL.WenXinTiSi("简介不能修改为空");
        }
    }
    void ChageRet()
    {
        BindingSource[0].SetActive(false);
    }
    void close()
    {
        Destroy(BindingSource[1].gameObject);
    }
    void ShowNumber()
    {
        MessageManager.GetInstance().Send7104(int.Parse(clubid.text));
    }
    void check()
    { 
        MessageManager.GetInstance().Send7111(int.Parse(clubid.text));
        SaveDate.GetInstance().JoinLm = false;
        GameObject temp = GameObject.Find("joinlms");
        if (temp)
        {
            temp.SetActive(false);
        }
    }
    void ADDcheck()
    {
        BindingSource[3].SetActive(true);
    }
    void Zhuan()
    {
        BindingSource[4].SetActive(true);
        ZhuanID.text = "";
        ZhuanMoney.text = "";
    }
    void Join()
    {
        BindingSource[2].SetActive(true);
    }
    void history()
    {
        MessageManager.GetInstance().Send7131(2,clubid.text);//LM战绩
    }
    void CreateRoom()
    {
        UIManager.ChangeUI(UIManager.PageState.CreateRoomPage, (GameObject obj) =>
        {
            obj.GetComponent<CreateRoomPage>().InformationSetting();
            CreateRoomController.GetInstance().CreateRoomType = "2";
            obj.GetComponent<CreateRoomPage>().ClubOrLianMengID = clubid.text;
        });

        DestroyImmediate(this.gameObject);
    }
    void JoinRet()
    {
        BindingSource[2].SetActive(false);
    }
    void SendJoinId()
    {
        if (clubidInput.text != null && clubidInput.text != "")
        {
            MessageManager.GetInstance().SendMsg784(int.Parse(clubidInput.text));
        }
        else
        {
            TooL.WenXinTiSi("您输入的格式有误，请检查后重新输入");
        }
    }
    void AdmianRet()
    {
        BindingSource[3].SetActive(false);
    }
    void AdmianOk()
    {
        if (AdmainInput.text != null && AdmainInput.text != "")
        {
            MessageManager.GetInstance().SendMsg7116(int.Parse(AdmainInput.text), int.Parse(clubid.text));
            AdmainInput.text = "";
        }
        else
        {
            TooL.WenXinTiSi("您的输入不合法");
        }
    }
    void ZhuanRet()
    {
        BindingSource[4].SetActive(false);
    }
    void Up()
    {
        if (allnumber.text == "2")
        {
            BindingSource[5].SetActive(true);//升级俱乐部面板
            UpClubOK.onClick.AddListener(  
               delegate { MessageManager.GetInstance().SendMsg7123(2, int.Parse(clubid.text)); });
        }
        else if ((allnumber.text == "4"))
        {
            BindingSource[5].SetActive(true);
            LmUptext.text = "联盟当前为中级，升级至高级联盟40000金币/月";
            UpClubOK.onClick.AddListener(
               delegate { MessageManager.GetInstance().SendMsg7123(3, int.Parse(clubid.text)); });
        }
        else if ((allnumber.text == "6"))
        {
            BindingSource[5].SetActive(true);
            LmUptext.text = "联盟当前为高级级，升级至传说级联盟60000金币/月";
            UpClubOK.onClick.AddListener(
               delegate { MessageManager.GetInstance().SendMsg7123(4, int.Parse(clubid.text)); });
        }
        else if ((allnumber.text == "8"))
        {
            BindingSource[5].SetActive(true);
            LmUptext.text = "联盟当前为传说级，升级至史诗级联盟80000金币/月";
            UpClubOK.onClick.AddListener(
               delegate { MessageManager.GetInstance().SendMsg7123(5, int.Parse(clubid.text)); });
        }
        else
        {
            TooL.WenXinTiSi("您的联盟已经升到最顶级了");
        }
    }
    void UpRet()
    {
        BindingSource[5].SetActive(false);
    }
    void ZhuanOk()
    {
        if (ZhuanID.text != "" && ZhuanMoney.text != "")
        {
            MessageManager.GetInstance().SendMsg781(int.Parse(ZhuanID.text), int.Parse(ZhuanMoney.text));
        }
        else
        {
            TooL.WenXinTiSi("您的输入不合法");
        }
    }
    void jieshanClub()
    {
        BindingSource[6].SetActive(true);
    }
    void jieshanOk()
    {
        BindingSource[6].SetActive(false);
        MessageManager.GetInstance().Send7119(int.Parse(clubid.text));
    }
    void jieshanDes()
    {
        BindingSource[6].SetActive(false);
    }
    void LMRenews() {
        MessageManager.GetInstance().Send7129(int.Parse(clubid.text));
    }
}
